<% layout("/inc/layout_page.html"){ %>

<form action="${BASE}/admin/AdminUser/changepasssave" id="form_save" method="post">
<div class="box">
<div class="box-body">
<table class="table tform table-border table-bordered">
  <tr>
    <th width="30%">登录名：</th>
    <td>
      <div class="col-xs-10">${obj.name}</div>
      <div class="col-xs-2"></div>
    </td>
  </tr>
  <tr>
    <th>真实姓名：</th>
    <td>
      <div class="col-xs-10">${obj.realName}</div>
      <div class="col-xs-2"></div>
    </td>
  </tr>
  <tr>
    <th>新密码：</th>
    <td>
      <input type="hidden" name="sid" id="sid" value="${obj.sid}">
      <div class="col-xs-10"><input id="n_password" name="n_password" type="password" class="form-control"></div>
      <div class="col-xs-2"></div>
    </td>
  </tr>
  <tr>
    <th>确认新密码：</th>
    <td>
      <div class="col-xs-10"><input id="r_password" name="r_password" type="password" class="form-control"></div>
      <div class="col-xs-2"></div>
    </td>
  </tr>
</table>
</div>
<div class="box-footer">
      <div class="col-xs-4"></div>
      <div class="col-xs-6">
        <button type="submit" class="btn btn-primary" ><i class="fa fa-save"></i> 保存</button>
        <a href="javascript:;" class="btn btn-default" id="a_btn_close"><i class="fa fa-reply"></i> 关闭</a>
      </div>
      <div class="col-xs-2"></div>
</div>
</div>

</form>

<script type="text/javascript">

$(function(){
	
	$("#a_btn_close").click(function(){
		layer_close();
	});

	$("#form_save").validate({
		errorPlacement: function(error, element) {
			error.appendTo(element.parent());
		},
		submitHandler : function(form) {
			layer.load(1, {shade: [0.3,'#fff']});
			$(form).ajaxSubmit({
				dataType:"json",
				success:function( jsondata ){
					layer.closeAll('loading');
					if( jsondata.code == "001" ){
						parent.toastr.success('密码修改成功！');
						layer_close();
					}else{
						parent.toastr.error(jsondata.msg);
					}
				}
			});
		},
		rules : {
			n_password : {
				required : true,
				minlength: 6
			},
			r_password : {
				required : true,
				minlength: 6,
		        equalTo: "#n_password"
			}
		}, 
		messages : { 
			n_password : { 
				required : "新密码不能为空",
				minlength : "密码长度不能小于 6 个字母"
			},
			r_password : { 
				required : "确认密码不能为空",
				minlength : "密码长度不能小于 6 个字母",
		        equalTo: "两次密码输入不一致"
			}
		}
	});
});
</script>
<% } %>